<template>
	<view class="box">
		<view class="titleBox">
			<text class="leftBorder"></text>
			<view class="left">
				<text>{{title}}</text>
			</view>
			<view class="right" v-if="categoryId">
				<navigator @click="goSort"
				:url="navigatorPath" open-type="switchTab">
					<text class="more">更多</text>
					<uni-icons type="forward" size="30rpx" color="#666666"></uni-icons>
				</navigator>
			</view>
		</view>

		<popuoSheet ref="popuoSheetRef"></popuoSheet> 
		<view class="contentBox">
			<!-- 骨架屏 -->
			<scroll-view scroll-x v-if="imageList.length<=0 && videoList.length <= 0 && skeleton"
				:class="fx === 0 ? 'imageBox H' : 'imageBox S'">
				<image v-for="(item,index) in 6" :key="index" src="" mode="aspectFill">
				</image>
			</scroll-view>
			<!-- 图 -->
			<scroll-view @longpress="popuoSheetRef?.open" scroll-x v-if="imageList.length>0" :class="fx === 0 ? 'imageBox H' : 'imageBox S'">
				<image @click="goToPreview(e, index, imageList, 'image')" lazy-load v-for="(item,index) in imageList"
					:key="index" :src="item.url" mode="aspectFill">
				</image>
			</scroll-view>
			<!-- 视频 -->
			<scroll-view scroll-x class="imageBox H" v-if="videoList.length>0">
				<video @click="goToPreview($event, index, videoList, 'video')" v-for="(item, index) in videoList"
					:key="index" autoplay loop muted :controls='false' object-fit='cover' :src="item.video_url">
				</video>
			</scroll-view>
		</view>
	</view>
</template>

<script setup>
	import popuoSheet from '../popup-sheet/popup-sheet.vue'
	import goToPreview from '@/utils/goToPreview.js'
	import {ref, computed } from 'vue'
	const navigatorPath = computed(()=>props.fx == 1 ? "/pages/scortVertical/scortVertical":"/pages/sortCross/sortCross")

	const props = defineProps({
		title: {
			type: String,
			default: '图片列表'
		},
		imageList: {
			type: Array,
			default: () => []
		},
		videoList: {
			type: Array,
			default: () => []
		},
		fx: {
			type: Number,
			default: 0
		},
		// 无图时是否显示骨架屏
		skeleton: {
			type: Boolean,
			default: false
		},
		categoryId: {
			type: String,
			default: ''
		}
	})
	const goSort = () => {
		// 设置缓存
		uni.setStorageSync('categoryId', props.categoryId)
		
	}
	
	// 反馈弹框
	// const popuoSheetRef = ref(null)
	
</script>

<style scoped lang="scss">
	.box {
		.titleBox {
			width: 686rpx;
			height: 50rpx;
			line-height: 50rpx;
			display: flex;
			align-items: center;
			margin: 0 auto;
			margin-top: 20rpx;

			.leftBorder {
				display: block;
				width: 10rpx;
				height: 100%;
				margin-right: 10rpx;
				background-color: $theme-bg-color2;
				border-radius: 15rpx;
			}

			.left {
				flex: 1;
				margin-left: 15rpx;
			}

			.right {
				display: flex;
				align-items: center;
				font-size: 26rpx;
				color: $text-font-color-3;

				.more {
					font-size: 26rpx;
				}
			}
		}

		.contentBox {
			.imageBox {
				width: 100%;
				margin-top: 28rpx;
				margin-left: 32rpx;
				margin-bottom: 28rpx;
				white-space: nowrap;

			}

			// 横向
			.H {

				image,
				video {
					border-radius: 18rpx;
					// border: solid 1px $text-font-color-4;
					width: 520rpx;
					height: 280rpx;
					display: inline-block;
					margin-right: 10rpx;

				}

				video {
					width: 495rpx;
					height: 280rpx;
				}

			}

			// 竖向
			.S {
				image {
					border-radius: 18rpx;
					width: 240rpx;
					height: 360rpx;
					display: inline-block;
					margin-right: 10rpx;
				}
			}

		}
	}
</style>